<?php

namespace app\models\merchant;

use app\models\Images;
use Yii;

/**
 * This is the model class for table "merchant_image".
 *
 * @property int $id
 * @property int $merchant_id
 * @property int $image_id
 * @property int $type 1 营业执照, 2 身份证, 3 实体店
 * @property string $create_time
 */
class MerchantImage extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'merchant_image';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['merchant_id', 'image_id', 'type'], 'integer'],
            [['type'], 'required'],
            [['create_time'], 'safe'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'merchant_id' => 'Merchant ID',
            'image_id' => 'Image ID',
            'type' => 'Type',
            'create_time' => 'Create Time',
        ];
    }

    public function getImage()
    {
        return $this->hasOne(Images::class, ['id' => 'image_id']);
    }
}
